﻿using UnityEngine;
using UnityStandardAssets;
using UnityStandardAssets.Characters;
using UnityStandardAssets.Characters.ThirdPerson;

namespace UnityStandardAssets.Characters.ThirdPerson
{
    public class WomanCharacterController : AICharacterControl
    {

        public new NavMeshAgent agent { get; private set; }             // the navmesh agent required for the path finding
        public new ThirdPersonCharacter character { get; private set; } // the character we are controlling
        public new Transform target;                                    // target to aim for
        public Transform AvoidPerson;                                   // person to avoid

        private void Start()
        {
            // get the components on the object we need ( should not be null due to require component so no need to check )
            agent = GetComponentInChildren<NavMeshAgent>();
            character = GetComponent<ThirdPersonCharacter>();

            agent.updateRotation = false;
            agent.updatePosition = true;
        }


        private void Update()
        {
            if (null != AvoidPerson)
            {
                //agent.SetDestination()
            }

            if (target != null)
                agent.SetDestination(target.position);

            if (agent.remainingDistance > agent.stoppingDistance)
                character.Move(agent.desiredVelocity, false, false);
            else
                character.Move(Vector3.zero, false, false);
        }


    }
}
